var MainServer = require('./MainServer')
var DataServer = require('./DataServer')
var ProxyPortServer = require('./ProxyPortServer')

var {Config, Proxy_Config} = require('./config')

const {Log} = require('./logger')


class MasterServer{

    constructor(){
        this.mainServer = null;
        this.dataServer = null;
    }

    start(){
        this.mainServer = new MainServer(Config.serverPort)
        this.dataServer = new DataServer(Config.serverDataPort, this.mainServer)
        this.mainServer.start()
        this.dataServer.start()
        Proxy_Config.forEach((item)=>{
            var pserver = new ProxyPortServer(item.port, item.slaveName, item.toPort, this.mainServer, DataServer)
            pserver.start()
        })
    }
}



var masterServer = new MasterServer()
Log.info('masterServer starting ....')
masterServer.start()

require('./WebServer')